package cron.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author : willian fu
 * @version : 1.0
 * @date : 2021/3/10 0010 15:08
 */
public class FileUtil {

    public static synchronized String readFileTxtStr(File file){
        BufferedReader reader = null;
        try {
            reader = new BufferedReader(new FileReader(file));
            StringBuilder javaStr = new StringBuilder();
            String line = "";
            while ((line = reader.readLine()) != null) {
                javaStr.append(line);
            }
            return javaStr.toString();
        } catch (IOException e) {
            return "";
        }finally {
            if (null != reader){
                try {
                    reader.close();
                } catch (IOException e) { }
            }
        }
    }

    public static synchronized String readFileTxtStr(String path){
        return readFileTxtStr(new File(path));
    }
}
